<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>wexp</Title>
            <Shortcut>wexp</Shortcut>
            <Description>winform附加属性</Description>
            <Author>singba</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>type</ID>
                    <ToolTip>类型</ToolTip>
                    <Default>int</Default>
                </Literal>
                <Literal>
                    <ID>property</ID>
                    <ToolTip>属性名称</ToolTip>
                    <Default>MyProperty</Default>
                </Literal>
                <Literal default="true" Editable="false">
                    <ID>ownerClass</ID>
                    <ToolTip>Owner Class</ToolTip>
                    <Function>ClassName()</Function> 
                </Literal>
                <Literal>
                    <ID>defaultValue</ID>
                    <ToolTip>默认值</ToolTip>
                    <Default>null</Default>
                </Literal>
                <Literal>
                    <ID>description</ID>
                    <ToolTip>说明</ToolTip>
                    <Default></Default>
                </Literal>
                <Literal>
                    <ID>category</ID>
                    <ToolTip>分类</ToolTip>
                    <Default>设置</Default>
                </Literal>
            </Declarations>
            <Code Language="csharp">
                <![CDATA[#region $property$ Extend Property
		Dictionary<Control, $type$> _$property$PropertyItems = new Dictionary<Control, $type$>();
		
        public void Set$property$(Control ctrl, $type$ value)
        {
            if (value < 0)
            {
                if (_$property$PropertyItems.ContainsKey(ctrl))
                {
                    _$property$PropertyItems.Remove(ctrl);
                }
                return;
            }
            else
            {
                _$property$PropertyItems[ctrl] = value;
            }
            On$property$Changed(ctrl,value);
        }

        [Category("$category$")]
        [Description("$description$")]
        [DefaultValue($defaultValue$)]
        public $type$ Get$property$(Control ctrl)
        {
            if (_$property$PropertyItems.TryGetValue(ctrl, out var value)) { return value; }
            return $defaultValue$;
        }
		
		void On$property$Changed(Control ctrl, $type$ value)
		{
			$end$
		}
			#endregion
			]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

